package com.wn.icloud.provider.uac.service;

import com.wn.icloud.biz.BaseBiz;
import com.wn.icloud.provider.uac.entity.Element;
import com.wn.icloud.provider.uac.mapper.ElementMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Rainer
 * @create 2017-06-23 20:27
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ElementBiz extends BaseBiz<ElementMapper, Element> {

    //    @Cache(key="permission:ele:u{1}")
    public List<Element> getAuthorityElementByUserId(String userId) {
        return mapper.selectAuthorityElementByUserId(userId);
    }

    public List<Element> getAuthorityElementByUserId(String userId, String menuId) {
        return mapper.selectAuthorityMenuElementByUserId(userId, menuId);
    }

    //    @Cache(key = "permission:ele")
    public List<Element> getAllElementPermissions() {
        return mapper.selectAllElementPermissions();
    }

    @Override
//    @CacheClear(keys = {"permission:ele", "permission"})
    public void insertSelective(Element entity) {
        super.insertSelective(entity);
    }

    @Override
//    @CacheClear(keys = {"permission:ele", "permission"})
    public void updateSelectiveById(Element entity) {
        super.updateSelectiveById(entity);
    }
}
